package cn.sc.summer.thread.config;

import cn.sc.summer.constant.factory.YamlPropertySourceFactory;
import org.dromara.dynamictp.core.spring.EnableDynamicTp;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * 类名：开启TP动态线程池
 *
 * @author a-xin
 * @date 2023/11/21 17:17
 */
@Configuration
@EnableDynamicTp
@PropertySource(value = "classpath:/summer-thread.yml", factory = YamlPropertySourceFactory.class)
public class DynamicTpThreadConfig {
    /*
     * 注入形式：
     * 注意，此处的线程池名称是根据nacos配置thread.yaml中的executors: - threadPoolName: dtpExecutor名称来定义
     * @Resource
     * private ThreadPoolExecutor dtpExecutor;
     *
     * 在使用时：
     * CompletableFuture<Void> userInfoFuture = CompletableFuture.runAsync(() -> {
     *         //具体的业务逻辑
     * }, dtpExecutor);
     */
}
